const path = require('path');
const nodeExternals = require('webpack-node-externals');

const requireContext = require('require-context')
const files = requireContext(path.join(__dirname, './src'), true, /\.js$/)

module.exports = {
  mode: 'production',
  entry: ['./src/export.js'],
  output: {
    path: path.resolve(__dirname, './dist'),
    libraryTarget: 'commonjs2',
    filename: 'index.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      },
      {
        test: /\.cm\.styl$/,
        loader: 'style-loader!css-loader?modules&camelCase&localIdentName=[local]-[hash:base64:5]!stylus-loader'
      }
    ]
  },
  externals: [nodeExternals()]
};